﻿// <copyright file="ReversibleDictionaryTests.cs" company="Sinbadsoft">
//        Copyright (c) Sinbadsoft 2009.
//        This file is released under the terms of the
//        GNU Library General Public License (LGPL) version 2.1
//        Please refer to the "License.txt" accompanying this file.
// </copyright>
// <author>Chaker NAKHLI</author>
// <email>Chaker.Nakhli@Sinbadsoft.com</email>
// <date>2009/03/07</date>

namespace Sinbadsoft.AdvancedCollections.Tests.ReversibleDictionary
{
    using System;
    using System.Collections.Generic;
    using MbUnit.Framework;

    [TestFixture]
    public static class ReversibleDictionaryTests
    {
        [StaticTestFactory]
        public static IEnumerable<Test> BuildTests()
        {
            TestFactoryHelper helper = new TestFactoryHelper(
                "ReversibleDictionary",
                Factory<int, int>, 
                Factory<string, string>);
            return helper.GenerateTests();
        }

        [Test]
        public static void ExceptionOnNullInitData()
        {
            Assert.Throws<ArgumentNullException>(
                delegate
                {
                    new ReversibleDictionary<int, int>(
                        null, 
                        EqualityComparer<int>.Default, 
                        EqualityComparer<int>.Default);
                });
        }

        [Test]
        public static void NoExceptionOnNullComparer()
        {
            Assert.DoesNotThrow(
                delegate
                {
                    new ReversibleDictionary<int, int>(null, EqualityComparer<int>.Default);
                    new ReversibleDictionary<int, int>(EqualityComparer<int>.Default, null);
                    new ReversibleDictionary<int, int>(null, null);
                });
        }

        private static IReversibleDictionary<TKey, TValue> Factory<TKey, TValue>(
            IEnumerable<KeyValuePair<TKey, TValue>> data)
        {
            return new ReversibleDictionary<TKey, TValue>(data);
        }
    }
}